package com.qiantu.phone.utils;

import java.util.ArrayList;
import java.util.List;

public class LambdaUtils{
    public  static <T> T findFirst(List<T> data,CompareInterface<T> compareI){
        for (T bean:data){
            if(compareI.compare(bean)){
                return bean;
            }
        }
        return null;
    }

    public  static <T> List<T> findAll(List<T> data,CompareInterface<T> compareI){
        List<T> beanList = new ArrayList<>();
        for (T bean:data){
            if(compareI.compare(bean)){
                beanList.add(bean);
            }
        }
        return beanList;
    }

    public  interface CompareInterface<T>{
        boolean compare(T bean);
    }
}
